import React, { Component } from "react";
import { HashRouter, Route, Switch, Redirect } from "react-router-dom";
import "./Admin.css";
//引入组件
import TopHeader from "../../components/TopHeader/TopHeader";
import LeftNav from "../../components/LeftNav/LeftNav";
//欢迎
import Welcome from "../welcome/Welcome";
import Notfound from "../notfound/Notfound";
import BillDetail from "../bill_manage/BillDetail";
//用户管理
import User from "../user_manage/User";
import Supplier from "../user_manage/Supplier";
//台账管理
import Bill from "../bill_manage/Bill";
import MaterialBill from "../bill_manage/MaterialBill";
//主数据管理
import AppointThreshold from "../data_manage/AppointThreshold";
import LoadingArea from "../data_manage/LoadingArea";
import ReplenishPlan from "../data_manage/ReplenishPlan";
//预约管理
import AppointApproval from "../appoint_manage/AppointApproval";
import AppointSearch from "../appoint_manage/AppointSearch";
import TodayPlan from "../appoint_manage/TodayPlan";
//车辆管理
import VehicleInfo from "../vehicle_manage/VehicleInfo";
import VehicleLine from "../vehicle_manage/VehicleLine";
import VehicleManage from "../vehicle_manage/VehicleManage";

import { Layout } from "antd";
const { Header, Footer, Sider, Content } = Layout;

export default class Admin extends Component {
  state = { user_name: "" };
  componentDidMount() {
    const user_name = window.sessionStorage.getItem("user_name") || "";
    this.setState({
      user_name,
    });
  }
  render() {
    const { user_name } = this.state;
    return (
      <div className="admin">
        <Layout className="layout">
          <Sider>
            <LeftNav></LeftNav>
          </Sider>
          <Layout>
            <Header>
              {user_name}
              <TopHeader></TopHeader>
            </Header>
            <Content
              style={{
                margin: "24px 16px",
                padding: 24,
                minHeight: 280,
                overflow: "auto",
              }}
            >
              <HashRouter>
                <Switch>
                  <Route path="/billDetail/:id" component={BillDetail}></Route>
                  <Route path="/welcome" component={Welcome}></Route>
                  <Route path="/users" component={User}></Route>
                  <Route path="/books" component={Bill}></Route>
                  <Route path="/books2" component={MaterialBill}></Route>
                  <Route
                    path="/appointThreshold"
                    component={AppointThreshold}
                  ></Route>
                  <Route path="/loadingArea" component={LoadingArea}></Route>
                  <Route
                    path="/replenishmentPlan"
                    component={ReplenishPlan}
                  ></Route>
                  <Route
                    path="/appointmentApproval"
                    component={AppointApproval}
                  ></Route>
                  <Route path="/AppointQuery" component={AppointSearch}></Route>
                  <Route path="/todayPlan" component={TodayPlan}></Route>
                  <Route path="/vehicleInfo" component={VehicleInfo}></Route>
                  <Route
                    path="/vehicleLineShow"
                    component={VehicleLine}
                  ></Route>
                  <Route path="/supacc" component={Supplier}></Route>
                  <Route path="/vehicleMange" component={VehicleManage}></Route>

                  <Redirect from="/" to="/welcome" exact></Redirect>
                  <Route path="*" component={Notfound}></Route>
                </Switch>
              </HashRouter>
            </Content>
          </Layout>
        </Layout>
      </div>
    );
  }
}
